#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/sendfile.h>
int main(int argc, char *argv[])
{
    int fileo,fileo1;
    size_t len;
    ssize_t copy;

    fileo=open(argv[1],O_RDONLY,00644);
    if(fileo==-1)
        perror("cannot open/creat file");

    fileo1=open(argv[2],O_RDWR|O_CREAT,00644);
    if(fileo1==-1)
        perror("cannot open/creat file");

    lseek(fileo,0,SEEK_SET);

    struct stat size;
    fstat(fileo,&size);
    len=size.st_size;

    copy=sendfile(fileo1,fileo,NULL,len);
    if(copy==-1)
        printf("failed to copy file\n");
    else
        printf("Copy successed!\n");
    return ;
}
